package com.sgcc.fj.pmos.e_fj_mall.bean;


import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

public class ComparisonDetailBackBean {

    private List<String> mainTypeList;//基准分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
    private List<String> floTypeList;//浮动分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04


    private List<Integer> monthSelectIndexList;

    private ArrayList<String> packageIdList;


    public ArrayList<String> getPackageIdList() {
        return packageIdList;
    }

    public void setPackageIdList(ArrayList<String> packageIdList) {
        this.packageIdList = packageIdList;
    }

    public List<Integer> getMonthSelectIndexList() {
        return monthSelectIndexList;
    }

    public void setMonthSelectIndexList(List<Integer> monthSelectIndexList) {
        this.monthSelectIndexList = monthSelectIndexList;
    }

    public List<String> getMainTypeList() {
        return mainTypeList;
    }

    public void setMainTypeList(List<String> mainTypeList) {
        this.mainTypeList = mainTypeList;
    }

    public List<String> getFloTypeList() {
        return floTypeList;
    }

    public void setFloTypeList(List<String> floTypeList) {
        this.floTypeList = floTypeList;
    }


    public int getType() {
        if (null != floTypeList && floTypeList.size() > 0 && null != mainTypeList && mainTypeList.size() > 0) {
            List<Boolean> interval = new ArrayList<>();
            List<Boolean> power = new ArrayList<>();

            //基准 分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
            //浮动分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
            for (String mainType : mainTypeList) {
                if (TextUtils.isEmpty(mainType)) {
                    interval.add(false);
                    power.add(false);
                } else {
                    if (mainType.equals("01")) {
                        interval.add(true);
                        power.add(true);
                    }
                    if (mainType.equals("02")) {
                        interval.add(true);
                        power.add(false);

                    }
                    if (mainType.equals("03")) {
                        interval.add(false);
                        power.add(true);
                    }
                    if (mainType.equals("04")) {
                        interval.add(false);
                        power.add(false);
                    }
                }
            }

            for (String floType : floTypeList) {
                if (TextUtils.isEmpty(floType)) {
                    interval.add(false);
                    power.add(false);

                } else {
                    if (floType.equals("01")) {
                        interval.add(true);
                        power.add(true);
                    }
                    if (floType.equals("02")) {
                        interval.add(true);
                        power.add(false);

                    }
                    if (floType.equals("03")) {
                        interval.add(false);
                        power.add(true);
                    }
                    if (floType.equals("04")) {
                        interval.add(false);
                        power.add(false);
                    }
                }
            }

            boolean isInterval = false;
            boolean isPower = false;


            for (int i = 1; i < interval.size(); i++) {
                isInterval = isInterval || interval.get(i - 1) || interval.get(i);

            }

            for (int i = 1; i < power.size(); i++) {
                isPower = isPower || power.get(i - 1) || power.get(i);
            }


            //  int type =-1;// 0分时 约定电量  1 分时 不约定电量  2不分时 约定电量  3 不分时 不约定电量
            if (isInterval && isPower )
                return 0;
            else if (isInterval )
                return 1;
            else if (isPower)
                return 2;
            else
                return 3;
        }
        return -1;

    }


}
